package com.andersen.web.service;

import com.andersen.database.dao.*;
import com.andersen.database.entity.ComponentEntity;
import com.andersen.database.entity.ComponentTypeEntity;
import com.andersen.database.entity.StateEntity;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Avseenko Dmitrij
 * Date: 05.03.14
 * Time: 11:25
 * To change this template use File | Settings | File Templates.
 */

@Service
public class ComponentService {

    public static final int SORT_DIRECTION_ASC = 0;
    public static final int SORT_DIRECTION_DESC = 1;
        
    //@Autowired
    //private ComponentTypeDao componentTypeDao;
    
    @Autowired
    private ComponentDao componentDao;

/*    public List<ComponentTypeEntity> getComponentsSubTypeForId(long id){

        return componentTypeDao.getComponentSubTypesByParentId(id);
    }*/
    
    public ComponentEntity getById(long id) {
        return componentDao.getComponentById(id);
    }
    
    public long[] addComponent(ComponentEntity component, StateEntity stateParams) {
        return componentDao.addComponent(component, stateParams);
    }
    
    public boolean updateComponent(ComponentEntity component) {
        return componentDao.updateComponent(component);
    }
    
    public List<ComponentEntity> getMajorComponentsForEmployee(long emplId) {
        return componentDao.getComponentsOfEmployee(emplId, false);
    }
    
    public List<ComponentEntity> getAllComponentsForEmployee(long emplId) {
        return componentDao.getComponentsOfEmployee(emplId, true);
    }
    
    public List<ComponentEntity> getConnectedComponents(long computerId) {
        return componentDao.getConnectedComponents(computerId);
    }

    public List<ComponentEntity> getComponentsByTypeId(long typeId) {
        List<Long> oneCat = new ArrayList<Long>();
        oneCat.add(typeId);
        return componentDao.getComponentsForTypeIds(oneCat);
    }

    public List<ComponentEntity> getComponentsByTypeIds(List<Long> ids) {
        return componentDao.getComponentsForTypeIds(ids);
    }
}
